{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-05-11T03:15:55.583179Z",
     "start_time": "2025-05-11T03:15:54.747255Z"
    }
   },
   "source": [
    "import pandas as pd\n",
    "\n",
    "train_df=pd.read_csv('../ml-1m/train_ratings.csv')\n",
    "test_df=pd.read_csv('../ml-1m/test_ratings.csv')\n",
    "neg_df=pd.read_csv('../ml-1m/negatives.csv')\n",
    "\n",
    "train_sample = train_df.sample(n=10, random_state=42)\n",
    "test_sample  = test_df.sample(n=10,  random_state=42)\n",
    "neg_sample   = neg_df.sample(n=10,   random_state=42)\n",
    "\n",
    "train_sample"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "        userId  itemId  rating\n",
       "780720    4689      64       1\n",
       "426026    2607    1042       1\n",
       "851279    5141     124       1\n",
       "826402    4998      69       1\n",
       "493700    3051     965       1\n",
       "244873    1488    1310       1\n",
       "247936    1502      59       1\n",
       "689736    4155     702       1\n",
       "492476    3043     116       1\n",
       "697121    4202     129       1"
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>userId</th>\n",
       "      <th>itemId</th>\n",
       "      <th>rating</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>780720</th>\n",
       "      <td>4689</td>\n",
       "      <td>64</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>426026</th>\n",
       "      <td>2607</td>\n",
       "      <td>1042</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>851279</th>\n",
       "      <td>5141</td>\n",
       "      <td>124</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>826402</th>\n",
       "      <td>4998</td>\n",
       "      <td>69</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>493700</th>\n",
       "      <td>3051</td>\n",
       "      <td>965</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>244873</th>\n",
       "      <td>1488</td>\n",
       "      <td>1310</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>247936</th>\n",
       "      <td>1502</td>\n",
       "      <td>59</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>689736</th>\n",
       "      <td>4155</td>\n",
       "      <td>702</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>492476</th>\n",
       "      <td>3043</td>\n",
       "      <td>116</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>697121</th>\n",
       "      <td>4202</td>\n",
       "      <td>129</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 6
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-05-11T03:15:55.598502Z",
     "start_time": "2025-05-11T03:15:55.584174Z"
    }
   },
   "cell_type": "code",
   "source": "test_sample \n",
   "id": "f77cef01daefba",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "      userId  itemId  rating\n",
       "5529    5529     396       1\n",
       "710      710     216       1\n",
       "4923    4923     958       1\n",
       "2153    2153     338       1\n",
       "1272    1272     792       1\n",
       "2316    2316    1208       1\n",
       "2094    2094     218       1\n",
       "3127    3127    1079       1\n",
       "742      742     350       1\n",
       "296      296     237       1"
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>userId</th>\n",
       "      <th>itemId</th>\n",
       "      <th>rating</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5529</th>\n",
       "      <td>5529</td>\n",
       "      <td>396</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>710</th>\n",
       "      <td>710</td>\n",
       "      <td>216</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4923</th>\n",
       "      <td>4923</td>\n",
       "      <td>958</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2153</th>\n",
       "      <td>2153</td>\n",
       "      <td>338</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1272</th>\n",
       "      <td>1272</td>\n",
       "      <td>792</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2316</th>\n",
       "      <td>2316</td>\n",
       "      <td>1208</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2094</th>\n",
       "      <td>2094</td>\n",
       "      <td>218</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3127</th>\n",
       "      <td>3127</td>\n",
       "      <td>1079</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>742</th>\n",
       "      <td>742</td>\n",
       "      <td>350</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>296</th>\n",
       "      <td>296</td>\n",
       "      <td>237</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 7
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-05-11T03:15:55.614502Z",
     "start_time": "2025-05-11T03:15:55.599514Z"
    }
   },
   "cell_type": "code",
   "source": "neg_sample",
   "id": "bf9c676bb8b0321a",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "      userId                                     negative_items  \\\n",
       "5529    5529  {0, 2, 6, 10, 11, 12, 14, 16, 21, 23, 24, 27, ...   \n",
       "710      710  {1, 2, 3, 4, 6, 7, 8, 10, 11, 12, 14, 16, 17, ...   \n",
       "4923    4923  {0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14...   \n",
       "2153    2153  {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14...   \n",
       "1272    1272  {1, 2, 3, 5, 7, 10, 11, 12, 14, 15, 16, 17, 18...   \n",
       "2316    2316  {1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1...   \n",
       "2094    2094  {0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16...   \n",
       "3127    3127  {1, 2, 3, 6, 7, 8, 10, 11, 12, 15, 16, 17, 18,...   \n",
       "742      742  {1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 14, 15, 1...   \n",
       "296      296  {1, 2, 3, 4, 6, 8, 10, 11, 12, 13, 14, 16, 17,...   \n",
       "\n",
       "                                       negative_samples  \n",
       "5529  [569, 3004, 102, 2671, 1695, 3697, 2957, 1735,...  \n",
       "710   [787, 2965, 1228, 2583, 1357, 524, 2405, 2968,...  \n",
       "4923  [1217, 710, 2131, 1572, 3097, 2417, 3252, 1025...  \n",
       "2153  [1717, 1153, 3397, 1491, 1254, 3661, 2928, 481...  \n",
       "1272  [1927, 2090, 259, 2036, 3087, 536, 3223, 2556,...  \n",
       "2316  [2683, 3232, 73, 2110, 954, 1520, 433, 1357, 7...  \n",
       "2094  [536, 2358, 2961, 3673, 994, 658, 2418, 2377, ...  \n",
       "3127  [2978, 1978, 3450, 1486, 2880, 3221, 1163, 329...  \n",
       "742   [2953, 1490, 1027, 1223, 2167, 2869, 469, 670,...  \n",
       "296   [1876, 1499, 2868, 2804, 3484, 1311, 2234, 281...  "
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>userId</th>\n",
       "      <th>negative_items</th>\n",
       "      <th>negative_samples</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5529</th>\n",
       "      <td>5529</td>\n",
       "      <td>{0, 2, 6, 10, 11, 12, 14, 16, 21, 23, 24, 27, ...</td>\n",
       "      <td>[569, 3004, 102, 2671, 1695, 3697, 2957, 1735,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>710</th>\n",
       "      <td>710</td>\n",
       "      <td>{1, 2, 3, 4, 6, 7, 8, 10, 11, 12, 14, 16, 17, ...</td>\n",
       "      <td>[787, 2965, 1228, 2583, 1357, 524, 2405, 2968,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4923</th>\n",
       "      <td>4923</td>\n",
       "      <td>{0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14...</td>\n",
       "      <td>[1217, 710, 2131, 1572, 3097, 2417, 3252, 1025...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2153</th>\n",
       "      <td>2153</td>\n",
       "      <td>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14...</td>\n",
       "      <td>[1717, 1153, 3397, 1491, 1254, 3661, 2928, 481...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1272</th>\n",
       "      <td>1272</td>\n",
       "      <td>{1, 2, 3, 5, 7, 10, 11, 12, 14, 15, 16, 17, 18...</td>\n",
       "      <td>[1927, 2090, 259, 2036, 3087, 536, 3223, 2556,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2316</th>\n",
       "      <td>2316</td>\n",
       "      <td>{1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1...</td>\n",
       "      <td>[2683, 3232, 73, 2110, 954, 1520, 433, 1357, 7...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2094</th>\n",
       "      <td>2094</td>\n",
       "      <td>{0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16...</td>\n",
       "      <td>[536, 2358, 2961, 3673, 994, 658, 2418, 2377, ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3127</th>\n",
       "      <td>3127</td>\n",
       "      <td>{1, 2, 3, 6, 7, 8, 10, 11, 12, 15, 16, 17, 18,...</td>\n",
       "      <td>[2978, 1978, 3450, 1486, 2880, 3221, 1163, 329...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>742</th>\n",
       "      <td>742</td>\n",
       "      <td>{1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 14, 15, 1...</td>\n",
       "      <td>[2953, 1490, 1027, 1223, 2167, 2869, 469, 670,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>296</th>\n",
       "      <td>296</td>\n",
       "      <td>{1, 2, 3, 4, 6, 8, 10, 11, 12, 13, 14, 16, 17,...</td>\n",
       "      <td>[1876, 1499, 2868, 2804, 3484, 1311, 2234, 281...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 8
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
